#!/usr/bin/python

import _thread
import time
import threading


flag = 0


def timestamp(msg, delay):
    global flag
    count = 0
    while count < 4:
        time.sleep(delay)
        count += 1
        # print(f"{msg}, {time.ctime(time.time())}")
    flag += 1


_thread.start_new_thread(timestamp, ("Jane", 2, ))
_thread.start_new_thread(timestamp, ("Peter", 1))

'''
while flag < 2:
    pass
'''


class Timestamp(threading.Thread):
    def __init__(self, who, delay):
        threading.Thread.__init__(self)
        self.who = who
        self.delay = delay

    def run(self):
        count = 0
        while count < 4:
            time.sleep(self.delay)
            count += 1
            print(f"{self.who}, {time.ctime(time.time())}")


Jone = Timestamp('Jone', 4)
Belt = Timestamp('Belt', 2)

Jone.start()
Belt.start()

# wait for all threads finished
for t in [Jone, Belt]:
    t.join()
